﻿CREATE TABLE [dbo].[Activity]
(
	[Model] [uniqueidentifier] NOT NULL, -- FK to Model
	[ActivityId] [uniqueidentifier] DEFAULT newid() NOT NULL,
	[Tags] [nvarchar](max) NULL,
	[Description] [nvarchar](max) NOT NULL,
	[Category] [uniqueidentifier] NULL, -- FK to Category
	[ResponsiblePerson] [uniqueidentifier] DEFAULT NULL, -- FK to Person
	[Priority] [int] DEFAULT 0 NOT NULL,
	[Progress] [int] DEFAULT 0 NOT NULL,
	[Quality] [int] NULL,
	[IsCompleted] [bit] DEFAULT 0 NOT NULL,
	[StartDate] [datetime] DEFAULT getdate() NOT NULL,
	[DueDate] [datetime] NULL,
	[Ended] [datetime] NULL,
	[IsTemplate] [bit] DEFAULT 0 NOT NULL,
	[IsHierarchical] [bit] DEFAULT 0 NOT NULL,
    [IsDeleted] [bit] DEFAULT 0 NOT NULL,
	[CreatedBy] [uniqueidentifier] NOT NULL, -- FK to Person
	[CreatedOn] [datetime] DEFAULT getdate() NOT NULL,
    [LastChanged] [datetime] DEFAULT getdate() NOT NULL,
	[LastChangedBy] [uniqueidentifier] NOT NULL, -- FK to Person
	[TimeStamp] [timestamp] NOT NULL

CONSTRAINT [PK_Activity] PRIMARY KEY CLUSTERED 
(
	[ActivityId] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO